<?php

namespace App\Service\H5;

use App\Constants\ErrorCode;
use App\Model\ComplaintRecordLog;
use App\Model\User;
use App\Service\BaseService;

/**
 * 新增投诉
 */
class ComplainRecordLogService extends BaseService
{
    public function handle()
    {
        $userId = $this->getUserId() ?? 0 ;
        $toUserId = $this->request->input('to_user_id', 0);
        $tmpLabel =  $this->request->input('label', '');
        $label =   $tmpLabel ?  explode(',',$tmpLabel) : [] ;

        $content = $this->request->input('content', '');
        $tmpImages = $this->request->input('images', '') ;
        $images = $tmpImages ? explode(',',$tmpImages) : [];

        $level = $this->request->input('level', 1);
        //是否管理员权限
        if (!User::isSuperAdmin($userId)) {
            return $this->setError(ErrorCode::OP_NOT_VALID, '暂无操作权限');
        }
        $ret = ComplaintRecordLog::addRecord($userId,$toUserId,$label,$content,$images,$level);
        return [];
    }
}
